package cn.com.w.jdk8.demo.reflect;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Set;

public class Test01 {


    public static void main(String[] args) {
        //Class exampleObjectClass = ExampleObject.class;

        String str = "yztb/createDownloadReturnFile2.action?key2=330802196704034461|tz_gaj_cer_052|";

        String[] strlist1 = str.split("[?]");

        String[] strlist2 = str.split("\\?");

        String[] strlist3 = str.split("action\\?");

        String s = "向乙公司.???";
        s = filterSpecialStr(s);
        System.out.println("s=" + s);
        String[] strlist5 = str.split(s);

        System.out.println("d");

    }

    /**
     * 过滤特殊字符
     *
     * @param sourceStr 源字符串
     * @return
     */
    public static String filterSpecialStr(String sourceStr) {
        if (StringUtils.isBlank(sourceStr)) {
            return "";
        }
        // 特殊字符
        List<String> specialStrs = Arrays.asList("+", "*", "|", "\\", "?", "^");
        StringBuilder sb = new StringBuilder();
        String[] split = sourceStr.split("");
        for (String s : split) {
            if (specialStrs.contains(s)) {
                sb.append("\\").append(s);
            } else {
                sb.append(s);
            }
        }
        return sb.toString();
    }

}
